package b3.widget.guide
{
	import b3.net.*;
	import b3.scene.*;
	import b3.widget.*;
	import b3.widget.basic.*;
	
	import com.greensock.*;
	
	import flash.display.*;
	import flash.events.*;

	public class PrefaceDialog extends BasicWidget
	{
		private var cityhall:Sprite;
		
		public function PrefaceDialog()
		{
			super();
			//背景
			var bgr:Sprite = new Sprite();
			var gfx:Graphics = bgr.graphics;
			gfx.beginFill(0x00AAAA);
			gfx.drawRect(0, 0, 760, 600);
			gfx.endFill();
			addChild(bgr);
			step1();
		}
		
		private function step1():void
		{
			var Cityhall:Class = ResourceHelper.getInstance().getClassByName("Drawing");
			cityhall = new Cityhall();
			cityhall.x = 197;
			cityhall.y = 120;
			addChild(cityhall);
			var dialog:TalkDialog = new TalkDialog("NpcDialogBgr3", ["旧城区已经陈旧，摇摇欲坠的房子已经构成了安全问题。"]);
			dialog.x = 360;
			dialog.y = 30;
			addChild(dialog);
			dialog.addEventListener(Event.REMOVED_FROM_STAGE, step2);
		}
		
		private function step2(event:Event):void
		{
			var WallPaper:Class = ResourceHelper.getInstance().getClassByName("WallPaper");
			var wallPaper:Sprite = new WallPaper();
			addChildAt(wallPaper, getChildIndex(cityhall));
			TweenLite.to(cityhall, 1, {alpha: 0.5, onComplete:step3});
		}
		
		private function step3():void
		{
			var NpcMajor:Class = ResourceHelper.getInstance().getClassByName("NpcMajor2");
			var npcMajor:Sprite = new NpcMajor();
			npcMajor.x = 0;
			npcMajor.y = 109;
			addChild(npcMajor);
			TweenLite.from(npcMajor, 1, {alpha: 0.5, onComplete:step4});
		}
		
		private function step4():void
		{
			var dialog:TalkDialog = new TalkDialog("NpcDialogBgr3", ["城区需要建更多的房子来满足人们的需求。", "但是找谁来进行城区建设比较合适呢？"]);
			dialog.x = 250;
			dialog.y = 50;
			addChild(dialog);
			dialog.addEventListener(Event.REMOVED_FROM_STAGE, step5);
		}
		
		private function step5(event:Event):void
		{
			var NpcSecretary:Class = ResourceHelper.getInstance().getClassByName("NpcSecretary2");
			var npcSecretary:Sprite = new NpcSecretary();
			npcSecretary.x = 418;
			npcSecretary.y = 102;
			addChild(npcSecretary);
			TweenLite.from(npcSecretary, 1, {alpha: 0.5, onComplete:step6});
		}
		
		private function step6():void
		{
			var dialog:TalkDialog = new TalkDialog("NpcDialogBgr2", ["把这个问题交给我吧，我知道有一个人能当此重任！"]);
			dialog.x = 180;
			dialog.y = 40;
			addChild(dialog);
			dialog.addEventListener(Event.REMOVED_FROM_STAGE, step7);
		}
		
		private function step7(event:Event):void
		{
			TweenLite.to(this, 1, {alpha: 0, onComplete:step8});
		}
		
		private function step8():void
		{
			var dialog:NpcDialog = new NpcDialog("NpcMajor1", ["谢天谢地，终于见到你了！我是本市的市长，李国龙。", 
				"听说你是国内最优秀的建筑师，新城区的建设就交给你了！"]);
			WidgetManager.getInstance().popOut([dialog], true);
			dialog.addEventListener(Event.REMOVED_FROM_STAGE, step9);
		}
		
		private function step9(event:Event):void
		{
			var dialog:NpcDialog = new NpcDialog("NpcSecretary1", ["我是你的助手小雯，让我开始教你怎么开展工作吧！"]);
			WidgetManager.getInstance().popOut([dialog], true);
			dialog.addEventListener(Event.REMOVED_FROM_STAGE, step10);
		}
		
		private function step10(event:Event):void
		{
			close();
			//加载蓝楼引导
			var blueBuildingGuide:BlueBuildingGuide = new BlueBuildingGuide();
			blueBuildingGuide.step1();
			SceneManager.getInstance().topLayer.addChild(blueBuildingGuide);
		}
	}
}